#pragma once
#include <ctime>
#include <cstdio>
#include <pthread.h>
#define INF 0
#define DBG 1
#define ERR 2
#define LOG_LEVEL DBG

#define LOG(level, format, ...)                                                                                         \
    do                                                                                                                  \
    {                                                                                                                   \
        if (level < LOG_LEVEL)                                                                                          \
        {                                                                                                               \
            break;                                                                                                      \
        }                                                                                                               \
        time_t tm = time(nullptr);                                                                                      \
        struct tm *t = localtime(&tm);                                                                                  \
        char time[15];                                                                                                  \
        strftime(time, 15, "%H:%M:%S", t);                                                                              \
        fprintf(stdout, "[%p %s %s:%d] " format "\n", (void *)pthread_self(), time, __FILE__, __LINE__, ##__VA_ARGS__); \
    } while (0);

#define INF_LOG(format, ...) LOG(INF, format, ##__VA_ARGS__)
#define DBG_LOG(format, ...) LOG(DBG, format, ##__VA_ARGS__)
#define ERR_LOG(format, ...) LOG(ERR, format, ##__VA_ARGS__)